package Models

import (
	"fmt"
	"strings"
)

type Paper struct {
	Formulas []Formula
	Title    string
	SubTitle string
}

func (this *Paper) Get() string {
	var build strings.Builder
	build.WriteString(fmt.Sprintln(this.Title))
	build.WriteString(fmt.Sprintln(this.SubTitle))
	for _, formula := range this.Formulas {
		build.WriteString(fmt.Sprintln(formula.WithEqualSign()))
	}
	return build.String()
}

func (this *Paper) GetPaper() string {
	var build strings.Builder
	build.WriteString(fmt.Sprintln(this.Title))
	build.WriteString(fmt.Sprintln(this.SubTitle))
	for i := 1; i <= len(this.Formulas); i++ {
		build.WriteString(fmt.Sprintf("%-15s", this.Formulas[i-1].WithEqualSign()))
		if i%4 > 0 {
			// build.WriteString("\t")
		} else {
			build.WriteString("\n")
		}
	}

	return build.String()
}

func (this *Paper) Put(formula *Formula) {
	if this.Formulas == nil {
		this.Formulas = make([]Formula, 0)
	}
	this.Formulas = append(this.Formulas, *formula)
}
